package com.wd.mine.fragment

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.activity.viewModels
import androidx.fragment.app.viewModels
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import com.wd.common.base.BaseFragment
import com.wd.common.bean.BuyCarBean
import com.wd.common.viewmodel.MyViewModel
import com.wd.mine.R
import com.wd.mine.adapter.OldCarListAdapter
import com.wd.mine.databinding.FragmentOldCarListBinding

class OldCarListFragment : BaseFragment<FragmentOldCarListBinding>() {
    override fun getViewBinding(
        inflater: LayoutInflater,
        container: ViewGroup?
    ): FragmentOldCarListBinding = FragmentOldCarListBinding.inflate(layoutInflater)

    val viewmodel: MyViewModel by viewModels()
    private var adapter: OldCarListAdapter? = null
    override fun initData() {
        viewmodel.query_buyoldcardetailsshoucangList(1, 5)
        viewmodel.query_buyoldcardetailsshoucangListLiveData.observe(this, Observer {
            adapter = context?.let { it1 -> OldCarListAdapter(it1, it.result) }
            binding.oldcarlistrecy.layoutManager = LinearLayoutManager(context)
            binding.oldcarlistrecy.adapter = adapter
        })
    }
}